package com.hy.mydesktop.server.dao;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;

import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.hy.enterprise.framework.persistence.PersistentException;
import com.hy.enterprise.framework.persistence.api.MyAbstractDao;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.util.GxtComponentMetaNodeModelUtil;

@Component("gxtComponentMetaNodeModelDao")
public class GxtComponentMetaNodeModelDaoImpl extends MyAbstractDao<GxtComponentMetaNodeModel>  implements
		GxtComponentMetaNodeModelDao<GxtComponentMetaNodeModel> {

	


	@Override
	public boolean contains(GxtComponentMetaNodeModel persistentEntity)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.contains(persistentEntity);
	}

	@Override
	public boolean contains(String identifier) throws PersistentException {
		// TODO Auto-generated method stub
		return super.contains(identifier);
	}

	

	@Override
	public Integer countByQuery(String query, Map<String, ?> parameters) {
		// TODO Auto-generated method stub
		return super.countByQuery(query, parameters);
	}

	@Override
	public Integer countByQuery(String query, Object... parameters) {
		// TODO Auto-generated method stub
		return super.countByQuery(query, parameters);
	}

	@Override
	public  List<GxtComponentMetaNodeModel> find() throws PersistentException {
		List<GxtComponentMetaNodeModel> list = super.find();
		return GxtComponentMetaNodeModelUtil.reconfigureGxtComponentMetaNodeModelsFromJpa(list);
		// return newList;
	}

	@Override
	public <T extends Serializable> List<T> find(int first, int max)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(first, max);
	}

	@Override
	public <T extends Serializable> List<T> find(int first, int max,
			String queryString, Object... values) throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(first, max, queryString, values);
	}

	@Override
	public <T extends Serializable> List<T> find(String queryString)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(queryString);
	}

	@Override
	public <T extends Serializable> List<T> find(String queryString, int first,
			int max) throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(queryString, first, max);
	}

	@Override
	public <T extends Serializable> List<T> find(String queryString,
			Map<String, ?> parameters) throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(queryString, parameters);
	}

	@Override
	public <T extends Serializable> List<T> find(String queryString,
			Map<String, ?> parameters, int first, int max)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(queryString, parameters, first, max);
	}

	@Override
	public <T extends Serializable> List<T> find(String queryString,
			Object... values) throws PersistentException {
		// TODO Auto-generated method stub
		return super.find(queryString, values);
	}

	@Override
	public <T extends Serializable> List<T> findByExample(Object exampleInstance) {
		// TODO Auto-generated method stub
		return super.findByExample(exampleInstance);
	}

	@Override
	public <T extends Serializable> List<T> findByExample(T exampleInstance,
			String[] excludeProperty) {
		// TODO Auto-generated method stub
		return super.findByExample(exampleInstance, excludeProperty);
	}

	@Override
	public GxtComponentMetaNodeModel findByIdentifier(String identifier)
			throws PersistentException {
		
		//GxtComponentMetaNodeModel gxtComponentMetaNodeModel = super.findById(identifier);
		GxtComponentMetaNodeModel gxtComponentMetaNodeModel =super.findUniqueResult("select o from GxtComponentMetaNodeModel as o where o.identifier='"+identifier+"'");

		//GxtComponentMetaNodeModelUtil.reconfigureGxtComponentMetaNodeModel(gxtComponentMetaNodeModel);
		 gxtComponentMetaNodeModel = GxtComponentMetaNodeModelUtil.reconfigureGxtComponentMetaNodeModelFromJpa(gxtComponentMetaNodeModel);
		
		return gxtComponentMetaNodeModel;
	}

	@Override
	public <T extends Serializable> List<T> findByIdentifier(String... identifiers)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByIdentifier(identifiers);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedParams(
			String queryString, Map<String, ?> parameters)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedParams(queryString, parameters);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedParams(
			String queryString, Map<String, ?> parameters, int first, int max)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedParams(queryString, parameters, first, max);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQuery(int first,
			int max, String queryName, Object... values)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQuery(first, max, queryName, values);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQuery(String queryName)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQuery(queryName);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQuery(String queryName,
			int first, int max) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQuery(queryName, first, max);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQuery(String queryName,
			Object... values) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQuery(queryName, values);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQueryAndNamedParams(
			String queryName, Map<String, ?> parameters)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQueryAndNamedParams(queryName, parameters);
	}

	@Override
	public <T extends Serializable> List<T> findByNamedQueryAndNamedParams(
			String queryName, Map<String, ?> parameters, int first, int max)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findByNamedQueryAndNamedParams(queryName, parameters, first, max);
	}

	@Override
	public <T extends Serializable> T findUniqueResult(String queryString)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResult(queryString);
	}

	@Override
	public <T extends Serializable> T findUniqueResult(String queryString,
			Map<String, ?> parameters) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResult(queryString, parameters);
	}

	@Override
	public <T extends Serializable> T findUniqueResult(String queryString,
			Object... values) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResult(queryString, values);
	}

	@Override
	public <T extends Serializable> T findUniqueResultByNamedParams(
			String queryName, Map<String, ?> parameters)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResultByNamedParams(queryName, parameters);
	}

	@Override
	public <T extends Serializable> T findUniqueResultByNamedQuery(
			String queryName) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResultByNamedQuery(queryName);
	}

	@Override
	public <T extends Serializable> T findUniqueResultByNamedQuery(
			String queryName, Object... values) throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResultByNamedQuery(queryName, values);
	}

	@Override
	public <T extends Serializable> T findUniqueResultByNamedQueryAndNamedParams(
			String queryName, Map<String, ?> parameters)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.findUniqueResultByNamedQueryAndNamedParams(queryName, parameters);
	}

	
	

	@Override
	public Class<GxtComponentMetaNodeModel> getPersistentEneityClass() {
		// TODO Auto-generated method stub
		return super.getPersistentEneityClass();
	}

	@Override
	public GxtComponentMetaNodeModel getReference(String identifier)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.getReference(identifier);
	}

	@Override
	public boolean isPropertyUnique(String propertyName, Object newValue,
			Object oldValue) {
		// TODO Auto-generated method stub
		return super.isPropertyUnique(propertyName, newValue, oldValue);
	}

	@Override
	public GxtComponentMetaNodeModel merge(
			GxtComponentMetaNodeModel persistentEntity)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.merge(persistentEntity);
	}

	@Override
	public boolean persist(GxtComponentMetaNodeModel persistentEntity)
			throws PersistentException {
		// TODO Auto-generated method stub
		GxtComponentMetaNodeModel gxtComponentMetaNodeModel = GxtComponentMetaNodeModelUtil.reConstructGxtComponentMetaNodeModel(persistentEntity);

		return super.persist(gxtComponentMetaNodeModel);
	}

	@Override
	public String[] persist(GxtComponentMetaNodeModel... persistentEntities)
			throws PersistentException {
		 GxtComponentMetaNodeModel[] list= GxtComponentMetaNodeModelUtil.reConstructGxtComponentMetaNodeModels(persistentEntities);
		return super.persist(list);
	}

	@Override
	public Integer persists(GxtComponentMetaNodeModel... persistentEntities)
			throws PersistentException {
		 GxtComponentMetaNodeModel[] list= GxtComponentMetaNodeModelUtil.reConstructGxtComponentMetaNodeModels(persistentEntities);
		return super.persists(list);
	}

	@Override
	public void refresh(GxtComponentMetaNodeModel persistentEntity)
			throws PersistentException {
		// TODO Auto-generated method stub
		super.refresh(persistentEntity);
	}

	@Override
	public boolean remove(GxtComponentMetaNodeModel persistentEntity)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.remove(persistentEntity);
	}

	@Override
	public Integer remove(GxtComponentMetaNodeModel... persistentEntities)
			throws PersistentException {
		// TODO Auto-generated method stub
		return super.remove(persistentEntities);
	}

	@Override
	public boolean remove(String identifier) throws PersistentException {
		// TODO Auto-generated method stub
		return super.remove(identifier);
	}

	@Override
	public Integer remove(String... identifiers) throws PersistentException {
		// TODO Auto-generated method stub
		return super.remove(identifiers);
	}

	@Override
	protected GxtComponentMetaNodeModel createEmptyEntity() {
		// TODO Auto-generated method stub
		return super.createEmptyEntity();
	}

	@Override
	protected Session getHibernateSession() {
		// TODO Auto-generated method stub
		return super.getHibernateSession();
	}

	@Override
	protected Query populateParameters(Query query, Map<String, ?> parameters) {
		// TODO Auto-generated method stub
		return super.populateParameters(query, parameters);
	}

	@Override
	protected Query populateParameters(Query query, Object... parameters) {
		// TODO Auto-generated method stub
		return super.populateParameters(query, parameters);
	}

	

	@Override
	public GxtComponentMetaNodeModel findByGxtComponentId(
			String id) {
		GxtComponentMetaNodeModel gxtComponentMetaNodeModel =super.findUniqueResult("select o from GxtComponentMetaNodeModel as o where o.id='"+id+"'");
		return gxtComponentMetaNodeModel;
	}

	@Override
	public boolean removeByGxtComponentId(String id) {
		
		return remove(this.findByGxtComponentId(id));
	}

	

}
